package com.leaf.lowcode.API;

import com.alibaba.fastjson.JSON;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import com.leaf.lowcode.entity.DevStatequest;
import com.leaf.lowcode.entity.GetDoorStateRequest;
import com.leaf.lowcode.entity.GetRequest;


import java.util.HashMap;
import java.util.Map;


/**
 * Auto Create on 2021-10-15 02:26:00
 */
public class DoorGateApi {
	/**
	 * STEP1：设置平台参数，根据实际情况,设置host appkey appsecret 三个参数.
	 */
	static {
		ArtemisConfig.host = "10.140.161.12:443";
		ArtemisConfig.appKey = "29544061"; // 秘钥appkey
		ArtemisConfig.appSecret = "N1Ims5vjYUTQIGdItUjc";
	}
	/**
	 * STEP2：设置OpenAPI接口的上下文
	 */
	private static final String ARTEMIS_PATH = "/artemis";

	//获取门禁设备在线状态
	public  String Devget(DevStatequest getRequest ){
		String getDataApi = ARTEMIS_PATH +"/api/nms/v1/online/acs_device/get";
		Map<String,String> path = new HashMap<String,String>(2){
			{
				put("https://",getDataApi);
			}
		};
		String body= JSON.toJSONString(getRequest);
		String result =ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
		return result;
	}

	//查询门禁点状态
	public static String doorstates(GetDoorStateRequest statesRequest ){
		String statesDataApi = ARTEMIS_PATH +"/api/acs/v1/door/states";
		Map<String,String> path = new HashMap<String,String>(2){
			{
				put("https://",statesDataApi);
			}
		};
		String body=JSON.toJSONString(statesRequest);
		String result =ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
		return result;
	}


	//获取门禁读卡器在线状态
	public  String Readerget(GetRequest getRequest ){
		String getDataApi = ARTEMIS_PATH +"/api/nms/v1/online/reader/get";
		Map<String,String> path = new HashMap<String,String>(2){
			{
				put("https://",getDataApi);
			}
		};
		String body=JSON.toJSONString(getRequest);
		String result =ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
		return result;
	}


}
